import "./detailMain.css";
import "../../../../components/loading/loading.css";

import { getData } from "../../../../api/getData";
import render from "./detailMain.art";

const regNum = /[0-9]+$/;

const id = window.location.search;

const baseUrl = "https://www.imooc.com/api/mall-wepApp/details/";
const containerEl = document.querySelector("#detail-main");
let sentUrl = baseUrl + regNum.exec(id)[0];

getData(sentUrl)
  .then((data) => {
    containerEl.innerHTML = render(data);
  })
  .catch((err) => console.log(err));
